package cn.chenhuanming.chuanzhi.util.entity;// default package

import cn.chenhuanming.chuanzhi.util.entity.converter.LocalDateConverter;
import cn.chenhuanming.chuanzhi.util.entity.view.View;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonView;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.springframework.format.annotation.DateTimeFormat;

import java.time.LocalDate;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.*;

/**
 * Staff entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "staff", catalog = "website")
@DynamicUpdate
@DynamicInsert
public class Staff implements java.io.Serializable {

	// Fields
	@JsonView(View.StaffListView.class)
	private String username;

	@JsonView(View.StaffListView.class)
	private String realName;

	private String password;

	@JsonView(View.StaffListView.class)
	private String sex;
	@JsonView(View.StaffListView.class)
	private String grade;
	private String major;
	private String github;
	private String phone;
	private String wechat;
	private String qq;
	private String area;

	@JsonView(View.StaffListView.class)
	private String department;

	@JsonView(View.StaffListView.class)
	private Short isSingle;

	@JsonView(View.StaffListView.class)
	@JsonFormat(pattern = "yyyy-MM-dd")
	private LocalDate inTime;

	private String acl;

	private Short status;

	@JsonIgnore
	private Set<Share> shares = new HashSet<Share>(0);

	// Constructors

	/** default constructor */
	public Staff() {
	}

	/** minimal constructor */
	public Staff(String username,String password) {
		this.username = username;
		this.password = password;
	}

	/** full constructor */
	public Staff(String username, String realName, String password,String sex,
			String grade, String major,String github, String phone, String wechat, String qq,
			String area, String department, Short isSingle, LocalDate inTime,
			String acl, Short status, Set<Share> shares) {
		this.username = username;
		this.realName = realName;
		this.password = password;
		this.sex = sex;
		this.grade = grade;
		this.major = major;
		this.github = github;
		this.phone = phone;
		this.wechat = wechat;
		this.qq = qq;
		this.area = area;
		this.department = department;
		this.isSingle = isSingle;
		this.inTime = inTime;
		this.acl = acl;
		this.status = status;
		this.shares = shares;
	}

	// Property accessors
	@Id
	@Column(name = "username", unique = true, nullable = false)
	public String getUsername() {
		return this.username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	@Column(name = "real_name")
	public String getRealName() {
		return this.realName;
	}

	public void setRealName(String realName) {
		this.realName = realName;
	}

	@Column(name = "password")
	public String getPassword() {
		return this.password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	@Column(name = "sex")
	public String getSex() {
		return sex;
	}

	public void setSex(String sex) {
		this.sex = sex;
	}

	@Column(name = "grade")
	public String getGrade() {
		return this.grade;
	}

	public void setGrade(String grade) {
		this.grade = grade;
	}

	@Column(name = "major")
	public String getMajor() {
		return this.major;
	}

	public void setMajor(String major) {
		this.major = major;
	}

	@Column(name = "github")
	public String getGithub() {
		return github;
	}

	public void setGithub(String github) {
		this.github = github;
	}

	@Column(name = "phone")
	public String getPhone() {
		return this.phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	@Column(name = "wechat")
	public String getWechat() {
		return this.wechat;
	}

	public void setWechat(String wechat) {
		this.wechat = wechat;
	}

	@Column(name = "qq")
	public String getQq() {
		return this.qq;
	}

	public void setQq(String qq) {
		this.qq = qq;
	}

	@Column(name = "area")
	public String getArea() {
		return this.area;
	}

	public void setArea(String area) {
		this.area = area;
	}

	@Column(name = "department")
	public String getDepartment() {
		return this.department;
	}

	public void setDepartment(String department) {
		this.department = department;
	}

	@Column(name = "is_single")
	public Short getIsSingle() {
		return this.isSingle;
	}

	public void setIsSingle(Short isSingle) {
		this.isSingle = isSingle;
	}

	@Convert(converter = LocalDateConverter.class)
	@DateTimeFormat(iso = DateTimeFormat.ISO.DATE)
	@Column(name = "in_time", length = 19)
	public LocalDate getInTime() {
		return this.inTime;
	}

	public void setInTime(LocalDate inTime) {
		this.inTime = inTime;
	}

	@Column(name = "acl", length = 0)
	public String getAcl() {
		return this.acl;
	}

	public void setAcl(String acl) {
		this.acl = acl;
	}

	@Column(name = "status")
	public Short getStatus() {
		return this.status;
	}

	public void setStatus(Short status) {
		this.status = status;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "staff")
	public Set<Share> getShares() {
		return this.shares;
	}

	public void setShares(Set<Share> shares) {
		this.shares = shares;
	}

}